<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2017/5/22
  Time: 11:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <jsp:include page="../../head.jsp"/>
    <title>基础数据维护</title>
    <script type="text/javascript">
        var formSetting = {
            title: "",
            module: 'save',
            numCount: '1',
            columns: [{
                index: "ID",
                name: "id",
                label: "id",
                hidden: true
            }, {
                index: "GROUP_ID",
                name: "groupId",
                label: "字典组ID",
                hidden: true
            }, {
                index: "DICTIONARY_CODE",
                name: "dictionaryCode",
                label: "字典代码"
            }, {
                index: "DICTIONARY_NAME",
                name: "dictionaryName",
                label: "字典名称",
                validate: 'validate[required]'
            }, {
                index: "DESCRIPT",
                name: "descript",
                label: "描述"
            }, {
                index: "STATUS",
                name: "status",
                label: "状态",
                type: "dropdown",
                data: [["启用", "0"], ["注销", "1"]],
                op: "eq",
                minLength: 0,
                validate: 'validate[required]'
            }],
            form: {
                'url': 'saveOrUpdate',
                'data': function () {
                    var id = "${id}";
                    if (id) {
                        var dataValue = "";
                        $.ajax({
                                   url: "findById?id=" + id,
                                   async: false,
                                   success: function (data) {
                                       dataValue = data;
                                   }
                               });
                        return dataValue;
                    } else {
                        return {"groupId": '${groupId}'};
                    }
                },
                'ajaxForm': {
                    success: function (result) {
                        alert(result.msg);
                    }
                }
            },
            buttons: {
                custom: [{
                    id: "backBtn",
                    value: "返回",
                    click: function () {
                        location.replace('/api/dictionary/mainPage?groupId=${groupId}');
//                        window.event.chancelBUbble = true;
//                        event.stopPropagation();
//                        event.target.history.back();
                    }
                }
                ]
            }
        };
        $(document).ready(function () {
            $("#dictionaryDataTable").mrdForm(formSetting);
        });
    </script>
</head>
<body>
<div id="dictionaryDataTable"></div>
</body>
</html>
